package com.meixiang.activity.account.manager;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.View;

import com.meixiang.R;
import com.meixiang.fragment.account.CheckRealNameFragment;
import com.meixiang.fragment.account.VerifyRealNameFragment;
import com.meixiang.http.HttpUtils;
import com.meixiang.main.BaseActivity;

/**
 * 实名认证
 *
 * @author LZRUI
 */
public class VerifyRealNameActivity extends BaseActivity {

    public static final String TAG = "VerifyRealNameActivity";

    /**
     * 是否已经认证，0 未认证 1认证
     */
    public static final String IS_AUTHENTICATION = "isAuthentication";

    private FragmentManager fragmentManager;

    private VerifyRealNameFragment verifyRealNameFragment;
    private CheckRealNameFragment checkRealNameFragment;

    private int isAuthentication = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_container);
        super.onCreate(savedInstanceState);
        if (getIntent() != null) {
            isAuthentication = getIntent().getIntExtra(IS_AUTHENTICATION, 0);
        }
        initFragment();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        HttpUtils.tagCancelRequest(TAG);
    }

    private void initFragment() {
        fragmentManager = getSupportFragmentManager();
        if (verifyRealNameFragment == null) {
            verifyRealNameFragment = VerifyRealNameFragment.newInstance();
        }
        if (checkRealNameFragment == null) {
            checkRealNameFragment = CheckRealNameFragment.newInstance();
        }
        if (isAuthentication == 0) {
            // 未认证
            fragmentManager.beginTransaction().add(R.id.fl_container, verifyRealNameFragment).commit();
        } else {
            // 已认证
            fragmentManager.beginTransaction().add(R.id.fl_container, checkRealNameFragment).commit();
        }
    }

    @Override
    protected void initTitle() {
        setTitle("实名认证");

    }

    @Override
    protected void initView() {

    }


    @Override
    protected void setData() {

    }

    @Override
    public void onClick(View v) {

    }
}
